using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes.DomainAttributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Enums;
using System.Collections.Generic;
using System.ComponentModel;

namespace Baci.ArcGIS._DataManagementTools._AttributeRules
{
    /// <summary>
    /// <para>Add Attribute Rule</para>
    /// <para>Adds an attribute rule to a dataset.</para>
    /// <para>将属性规则添加到数据集。</para>
    /// </summary>    
    [DisplayName("Add Attribute Rule")]
    public class AddAttributeRule : AbstractGPProcess
    {
        /// <summary>
        /// 无参构造
        /// </summary>
        public AddAttributeRule()
        {

        }

        /// <summary>
        /// 有参构造
        /// </summary>
        /// <param name="_in_table">
        /// <para>Input Table</para>
        /// <para>The table or feature class that will have the new rule applied.</para>
        /// <para>将应用新规则的表或要素类。</para>
        /// </param>
        /// <param name="_name">
        /// <para>Name</para>
        /// <para>A unique name for the new rule.</para>
        /// <para>新规则的唯一名称。</para>
        /// </param>
        /// <param name="_type">
        /// <para>Type</para>
        /// <para><xdoc>
        ///   <para>Specifies the type of attribute rule to add.</para>
        ///   <bulletList>
        ///     <bullet_item>Calculation—Automatically populate attribute values for features when another attribute is set on a feature. These rules are applied based on the triggering events specified. Long running calculations can be set to run in batch mode and will be evaluated at a user-defined time.When adding multiple calculation rules, the order in which the rules are added is important if there are circular dependencies. For example, Rule A calculates Field1 is equal to the value of $feature.Field2 + $feature.Field3, and Rule B calculates Field4 is equal to $feature.Field1 + $feature.Field5; the results of the calculation may be different depending on the order in which the rules are added.</bullet_item><para/>
        ///     <bullet_item>Constraint—Specify permissible attribute configurations on a feature. When the constraint rule is violated, an error is generated and the feature is not stored. For example, if the value of Field A must be less than the sum of Field B and Field C, an error will be generated when that constraint is violated.</bullet_item><para/>
        ///     <bullet_item>Validation—Check for existing features with a batch validation process. Rules are evaluated at a user-defined time. When a rule is violated, an error feature is created. The type of rule can only be used for data that has been set up for branch versioning.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定要添加的属性规则的类型。</para>
        ///   <bulletList>
        ///     <bullet_item>计算 - 在要素上设置另一个属性时，自动填充要素的属性值。这些规则是根据指定的触发事件应用的。长时间运行的计算可以设置为在批处理模式下运行，并将在用户定义的时间进行评估。添加多个计算规则时，如果存在循环依赖关系，则添加规则的顺序很重要。例如，规则 A 计算 Field1 等于 $feature 的值。字段 2 + $feature。Field3，规则 B 计算 Field4 等于 $feature。字段 1 + $feature。字段5;根据添加规则的顺序，计算结果可能会有所不同。</bullet_item><para/>
        ///     <bullet_item>约束 （Constraint） - 指定要素上允许的属性配置。当违反约束规则时，将生成错误，并且不会存储要素。例如，如果字段 A 的值必须小于字段 B 和字段 C 的总和，则在违反该约束时将生成错误。</bullet_item><para/>
        ///     <bullet_item>验证 - 使用批量验证过程检查现有要素。规则在用户定义的时间进行评估。违反规则时，将创建错误功能。规则类型只能用于已为分支版本控制设置的数据。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// </param>
        /// <param name="_script_expression">
        /// <para>Script Expression</para>
        /// <para>The Arcade expression that defines the rule.</para>
        /// <para>定义规则的 Arcade 表达式。</para>
        /// </param>
        public AddAttributeRule(object _in_table, object _name, _type_value? _type, object _script_expression)
        {
            this._in_table = _in_table;
            this._name = _name;
            this._type = _type;
            this._script_expression = _script_expression;
        }
        public override string ToolboxName => "Data Management Tools";

        public override string ToolName => "Add Attribute Rule";

        public override string CallName => "management.AddAttributeRule";

        public override List<string> AcceptEnvironments => ["workspace"];

        public override object[] ParameterInfo => [_in_table, _name, _type.GetGPValue(), _script_expression, _is_editable.GetGPValue(), _triggering_events, _error_number, _error_message, _description, _subtype, _field, _exclude_from_client_evaluation.GetGPValue(), _out_table, _batch.GetGPValue(), _severity, _tags];

        /// <summary>
        /// <para>Input Table</para>
        /// <para>The table or feature class that will have the new rule applied.</para>
        /// <para>将应用新规则的表或要素类。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Input Table")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _in_table { get; set; }


        /// <summary>
        /// <para>Name</para>
        /// <para>A unique name for the new rule.</para>
        /// <para>新规则的唯一名称。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Name")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _name { get; set; }


        /// <summary>
        /// <para>Type</para>
        /// <para><xdoc>
        ///   <para>Specifies the type of attribute rule to add.</para>
        ///   <bulletList>
        ///     <bullet_item>Calculation—Automatically populate attribute values for features when another attribute is set on a feature. These rules are applied based on the triggering events specified. Long running calculations can be set to run in batch mode and will be evaluated at a user-defined time.When adding multiple calculation rules, the order in which the rules are added is important if there are circular dependencies. For example, Rule A calculates Field1 is equal to the value of $feature.Field2 + $feature.Field3, and Rule B calculates Field4 is equal to $feature.Field1 + $feature.Field5; the results of the calculation may be different depending on the order in which the rules are added.</bullet_item><para/>
        ///     <bullet_item>Constraint—Specify permissible attribute configurations on a feature. When the constraint rule is violated, an error is generated and the feature is not stored. For example, if the value of Field A must be less than the sum of Field B and Field C, an error will be generated when that constraint is violated.</bullet_item><para/>
        ///     <bullet_item>Validation—Check for existing features with a batch validation process. Rules are evaluated at a user-defined time. When a rule is violated, an error feature is created. The type of rule can only be used for data that has been set up for branch versioning.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定要添加的属性规则的类型。</para>
        ///   <bulletList>
        ///     <bullet_item>计算 - 在要素上设置另一个属性时，自动填充要素的属性值。这些规则是根据指定的触发事件应用的。长时间运行的计算可以设置为在批处理模式下运行，并将在用户定义的时间进行评估。添加多个计算规则时，如果存在循环依赖关系，则添加规则的顺序很重要。例如，规则 A 计算 Field1 等于 $feature 的值。字段 2 + $feature。Field3，规则 B 计算 Field4 等于 $feature。字段 1 + $feature。字段5;根据添加规则的顺序，计算结果可能会有所不同。</bullet_item><para/>
        ///     <bullet_item>约束 （Constraint） - 指定要素上允许的属性配置。当违反约束规则时，将生成错误，并且不会存储要素。例如，如果字段 A 的值必须小于字段 B 和字段 C 的总和，则在违反该约束时将生成错误。</bullet_item><para/>
        ///     <bullet_item>验证 - 使用批量验证过程检查现有要素。规则在用户定义的时间进行评估。违反规则时，将创建错误功能。规则类型只能用于已为分支版本控制设置的数据。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Type")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public _type_value? _type { get; set; }

        public enum _type_value
        {
            /// <summary>
            /// <para>Calculation</para>
            /// <para>Calculation—Automatically populate attribute values for features when another attribute is set on a feature. These rules are applied based on the triggering events specified. Long running calculations can be set to run in batch mode and will be evaluated at a user-defined time.When adding multiple calculation rules, the order in which the rules are added is important if there are circular dependencies. For example, Rule A calculates Field1 is equal to the value of $feature.Field2 + $feature.Field3, and Rule B calculates Field4 is equal to $feature.Field1 + $feature.Field5; the results of the calculation may be different depending on the order in which the rules are added.</para>
            /// <para>计算 - 在要素上设置另一个属性时，自动填充要素的属性值。这些规则是根据指定的触发事件应用的。长时间运行的计算可以设置为在批处理模式下运行，并将在用户定义的时间进行评估。添加多个计算规则时，如果存在循环依赖关系，则添加规则的顺序很重要。例如，规则 A 计算 Field1 等于 $feature 的值。字段 2 + $feature。Field3，规则 B 计算 Field4 等于 $feature。字段 1 + $feature。字段5;根据添加规则的顺序，计算结果可能会有所不同。</para>
            /// </summary>
            [Description("Calculation")]
            [GPEnumValue("CALCULATION")]
            _CALCULATION,

            /// <summary>
            /// <para>Constraint</para>
            /// <para>Constraint—Specify permissible attribute configurations on a feature. When the constraint rule is violated, an error is generated and the feature is not stored. For example, if the value of Field A must be less than the sum of Field B and Field C, an error will be generated when that constraint is violated.</para>
            /// <para>约束 （Constraint） - 指定要素上允许的属性配置。当违反约束规则时，将生成错误，并且不会存储要素。例如，如果字段 A 的值必须小于字段 B 和字段 C 的总和，则在违反该约束时将生成错误。</para>
            /// </summary>
            [Description("Constraint")]
            [GPEnumValue("CONSTRAINT")]
            _CONSTRAINT,

            /// <summary>
            /// <para>Validation</para>
            /// <para>Validation—Check for existing features with a batch validation process. Rules are evaluated at a user-defined time. When a rule is violated, an error feature is created. The type of rule can only be used for data that has been set up for branch versioning.</para>
            /// <para>验证 - 使用批量验证过程检查现有要素。规则在用户定义的时间进行评估。违反规则时，将创建错误功能。规则类型只能用于已为分支版本控制设置的数据。</para>
            /// </summary>
            [Description("Validation")]
            [GPEnumValue("VALIDATION")]
            _VALIDATION,

        }

        /// <summary>
        /// <para>Script Expression</para>
        /// <para>The Arcade expression that defines the rule.</para>
        /// <para>定义规则的 Arcade 表达式。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Script Expression")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _script_expression { get; set; }


        /// <summary>
        /// <para>Is Editable</para>
        /// <para><xdoc>
        ///   <para>Specifies whether the attribute value can be edited. Attribute rules can be configured to either block or allow editors to edit the attribute values of the field being calculated. This parameter is only applicable for the calculation attribute rule type.
        ///   <bulletList>
        ///     <bullet_item>Checked—Editors will be able to edit the attribute value. This is the default.  </bullet_item><para/>
        ///     <bullet_item>Unchecked—Editors will not be able to edit the attribute value.  </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para><xdoc>
        /// <para>指定是否可以编辑属性值。可以将属性规则配置为阻止或允许编辑者编辑正在计算的字段的属性值。此参数仅适用于计算属性规则类型。
        ///   <bulletList>
        ///     <bullet_item>选中 - 编辑者将能够编辑属性值。这是默认设置。 </bullet_item><para/>
        ///     <bullet_item>未选中 - 编辑者将无法编辑属性值。</bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Is Editable")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _is_editable_value _is_editable { get; set; } = _is_editable_value._true;

        public enum _is_editable_value
        {
            /// <summary>
            /// <para>EDITABLE</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("EDITABLE")]
            [GPEnumValue("true")]
            _true,

            /// <summary>
            /// <para>NONEDITABLE</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("NONEDITABLE")]
            [GPEnumValue("false")]
            _false,

        }

        /// <summary>
        /// <para>Triggering Events</para>
        /// <para><xdoc>
        ///   <para>Specifies the editing events that will trigger the attribute rule to take effect. This parameter is valid for calculation and constraint rule types only. At least one triggering event must be provided for calculation rules in which the Batch parameter is unchecked (batch = "NOT_BATCH" in Python). Triggering events are not applicable for calculation rules that have the Batch parameter checked (batch = "BATCH" in Python).</para>
        ///   <bulletList>
        ///     <bullet_item>Insert—The rule will be applied when a new feature is added.</bullet_item><para/>
        ///     <bullet_item>Update—The rule will be applied when a feature is updated.</bullet_item><para/>
        ///     <bullet_item>Delete—The rule will be applied when a feature is deleted.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定将触发属性规则生效的编辑事件。此参数仅对计算规则和约束规则类型有效。对于未选中 Batch 参数的计算规则，必须至少提供一个触发事件（Python 中为 batch = “NOT_BATCH”）。触发事件不适用于选中了 Batch 参数的计算规则（Python 中为 batch = “BATCH”）。</para>
        ///   <bulletList>
        ///     <bullet_item>插入 - 添加新要素时将应用规则。</bullet_item><para/>
        ///     <bullet_item>更新 - 更新要素时将应用规则。</bullet_item><para/>
        ///     <bullet_item>删除 - 删除要素时将应用规则。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Triggering Events")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public List<object> _triggering_events { get; set; } = null;


        /// <summary>
        /// <para>Error Number</para>
        /// <para><xdoc>
        ///   <para>An error number that will be returned when this rule is violated. This value is not required to be unique, so you may have the same custom error number returned for multiple rules.</para>
        ///   <para>This parameter is required for the constraint and validation rules. It is optional for calculation rules.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>违反此规则时将返回的错误号。此值不需要是唯一的，因此您可以为多个规则返回相同的自定义错误号。</para>
        ///   <para>此参数对于约束规则和验证规则是必需的。对于计算规则，它是可选的。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Error Number")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _error_number { get; set; } = null;


        /// <summary>
        /// <para>Error Message</para>
        /// <para><xdoc>
        ///   <para>An error message that will be returned when this rule is violated. It is recommended that you use a descriptive message to help the editor understand the violation when it occurs. The message is limited to 2000 characters.</para>
        ///   <para>This parameter is required for the constraint and validation rules. It is optional for calculation rules.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>违反此规则时将返回的错误消息。建议您使用描述性消息来帮助编辑者了解发生违规的情况。消息限制为 2000 个字符。</para>
        ///   <para>此参数对于约束规则和验证规则是必需的。对于计算规则，它是可选的。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Error Message")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _error_message { get; set; } = null;


        /// <summary>
        /// <para>Description</para>
        /// <para>The description of the new attribute rule. The description is limited to 256 characters.</para>
        /// <para>新属性规则的说明。描述限制为 256 个字符。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Description")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _description { get; set; } = null;


        /// <summary>
        /// <para>Subtype</para>
        /// <para>The subtype to which the rule will be applied if the dataset has subtypes.</para>
        /// <para>如果数据集具有子类型，则将应用规则的子类型。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Subtype")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _subtype { get; set; } = null;


        /// <summary>
        /// <para>Field</para>
        /// <para>The name of an existing field to which the rule will be applied. This parameter is only applicable for the calculation attribute rule type.</para>
        /// <para>将应用规则的现有字段的名称。此参数仅适用于计算属性规则类型。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Field")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _field { get; set; } = null;


        /// <summary>
        /// <para>Exclude from application evaluation</para>
        /// <para><xdoc>
        ///   <para>Specifies whether the rule will be excluded from evaluation before edits are applied. Because not all clients may have the capability to run all of the available rules, you can choose to flag a rule for simple clients only. For example, some rules may refer to data that has not been made available to all clients (reasons can include the data is offline, size, or security), or some rules may depend on the user or context (that is, a lightweight field update in ArcGIS Collector may not execute a rule that requires additional user input or knowledge; however, a client such as ArcGIS Pro may support it). This parameter is not applicable for validation rules or calculation rules if the Batch parameter is checked.
        ///   <bulletList>
        ///     <bullet_item>Checked—The rule will be excluded from client evaluation.  </bullet_item><para/>
        ///     <bullet_item>Unchecked—The rule will be executed for all clients. This is the default.  </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        ///   <para>Prior to ArcGIS Pro 2.4, this parameter was labeled Server only.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        /// <para>指定在应用编辑之前是否从评估中排除规则。由于并非所有客户端都能够运行所有可用规则，因此可以选择仅为简单客户端标记规则。例如，某些规则可能引用尚未提供给所有客户端的数据（原因可能包括数据处于离线状态、大小或安全性），或者某些规则可能取决于用户或上下文（即，ArcGIS Collector 中的轻量级字段更新可能不会执行需要其他用户输入或知识的规则;但是， 客户端（例如 ArcGIS Pro）可能支持它）。如果选中了 Batch 参数，则该参数不适用于验证规则或计算规则。
        ///   <bulletList>
        ///     <bullet_item>选中 - 规则将从客户端评估中排除。</bullet_item><para/>
        ///     <bullet_item>未选中 - 将对所有客户端执行该规则。这是默认设置。 </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        ///   <para>在 ArcGIS Pro 2.4 之前，此参数仅标记为服务器。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Exclude from application evaluation")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _exclude_from_client_evaluation_value _exclude_from_client_evaluation { get; set; } = _exclude_from_client_evaluation_value._false;

        public enum _exclude_from_client_evaluation_value
        {
            /// <summary>
            /// <para>EXCLUDE</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("EXCLUDE")]
            [GPEnumValue("true")]
            _true,

            /// <summary>
            /// <para>INCLUDE</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("INCLUDE")]
            [GPEnumValue("false")]
            _false,

        }

        /// <summary>
        /// <para>Attribute Rule Added</para>
        /// <para></para>
        /// <para></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Attribute Rule Added")]
        [Description("")]
        [Option(OptionTypeEnum.derived)]
        public object _out_table { get; set; }


        /// <summary>
        /// <para>Batch</para>
        /// <para><xdoc>
        ///   <para>Specifies whether the rule evaluation will be executed in batch mode.
        ///   <bulletList>
        ///     <bullet_item>Checked—The rule evaluation will be executed in batch mode at a later time by executing validate.  </bullet_item><para/>
        ///     <bullet_item>Unchecked—The rule evaluation will not be executed in batch mode. Triggering events will be used to determine when the rule is evaluated for insert, update, or delete edit operations. This is the default.  </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        ///   <para>Calculation rules can be either checked or unchecked. Validation rules are always checked for this parameter, and constraint rules are always unchecked.</para>
        ///   <para>Batch rules are only supported for data with branch versioning enabled.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        /// <para>指定是否在批处理模式下执行规则评估。
        ///   <bulletList>
        ///     <bullet_item>选中 - 稍后将通过执行验证以批处理模式执行规则评估。</bullet_item><para/>
        ///     <bullet_item>未选中 - 规则评估不会在批处理模式下执行。触发事件将用于确定何时评估插入、更新或删除编辑操作的规则。这是默认设置。 </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        ///   <para>计算规则可以选中或取消选中。始终检查此参数的验证规则，并且始终未选中约束规则。</para>
        ///   <para>只有启用了分支版本控制的数据才支持批处理规则。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Batch")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _batch_value _batch { get; set; } = _batch_value._false;

        public enum _batch_value
        {
            /// <summary>
            /// <para>BATCH</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("BATCH")]
            [GPEnumValue("true")]
            _true,

            /// <summary>
            /// <para>NOT_BATCH</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("NOT_BATCH")]
            [GPEnumValue("false")]
            _false,

        }

        /// <summary>
        /// <para>Severity</para>
        /// <para><xdoc>
        ///   <para>The severity of the error.</para>
        ///   <para>A value within the range of 1 through 5 can be chosen to define the severity of the rule. A value of 1 is high, being the most severe, and a value of 5 is low, being the least severe. For example, you can provide a low severity for a specific attribute rule and ignore the error during data production workflows, or set a high severity in which the error would need to be fixed for accuracy of data collected.</para>
        ///   <para>This parameter is only applicable to validation rules.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>错误的严重性。</para>
        ///   <para>可以选择 1 到 5 范围内的值来定义规则的严重性。值 1 表示高，表示最严重，值 5 表示低，表示最不严重。例如，您可以为特定属性规则提供低严重性，并在数据生产工作流期间忽略该错误，或者设置一个高严重性，在该严重性下需要修复错误以确保所收集数据的准确性。</para>
        ///   <para>该参数仅适用于验证规则。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Severity")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public long? _severity { get; set; } = null;


        /// <summary>
        /// <para>Tags</para>
        /// <para>A set of tags that identify the rule (searchable and indexable) as a way to map to a functional requirement in a data model.</para>
        /// <para>一组标记，用于标识规则（可搜索和可索引）作为映射到数据模型中功能需求的一种方式。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Tags")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public List<object> _tags { get; set; } = null;


        public AddAttributeRule SetEnv(object workspace = null)
        {
            base.SetEnv(workspace: workspace);
            return this;
        }

    }

}